﻿using System;
using Transport;
using Microsoft.Research.Kinect.Audio;
using Microsoft.Research.Kinect.Nui;
namespace Capture
{
    /// <summary>
    /// KinectCapturer
    /// </summary>
    public class KinectCapturer : ICapturer
    {
        private Runtime _runtime;
        private KinectAudioSource _audio;
        private ImageStream _video;
        private IAudioTransport _audioEncoder;
        private IVideoTransport _videoEncoder;

        public KinectCapturer(IAudioTransport audioEncoder, IVideoTransport videoEncoder)
        {
            if (audioEncoder == null)
                throw new ArgumentNullException("audioEncoder");
            if (videoEncoder == null)
                throw new ArgumentNullException("videoEncoder");
            _audioEncoder = audioEncoder;
            _videoEncoder = videoEncoder;
            //
            _runtime = new Runtime();
            try { _audio = new KinectAudioSource(); }
            catch { }
        }
        public void Dispose()
        {
            _audioEncoder.Dispose();
            _videoEncoder.Dispose();
            if (_audio != null)
                _audio.Dispose();
        }

        public static bool IsSupported
        {
            get { return false; }
        }

        public void Initialize()
        {
        }

        public void Start()
        {
            if (_audio != null)
                _audio.Start();
        }

        public void Stop()
        {
            if (_audio != null)
                _audio.Stop();
        }
    }
}
